﻿using Microsoft.AspNetCore.Mvc;
using NlpApp.Bll;
using NlpApp.Bll.Personalize;
using NlpApp.Model;
using System.Threading.Tasks;

namespace NlpApp.Webapi.Controllers
{
    /// <summary>
    /// Class NlpAppController.
    /// Implements the <see cref="ControllerBase" />
    /// </summary>
    /// <seealso cref="ControllerBase" />
    [ApiController]
    [Route("")]
    public class NlpController : ControllerBase
    {
        private readonly ServiceBll serviceBll;
        private readonly WS010000190 wS010000190;

        /// <summary>
        /// Initializes a new instance of the <see cref="NlpController"/> class.
        /// </summary>
        /// <param name="serviceBll"></param>
        public NlpController(ServiceBll serviceBll, WS010000190 wS010000190)
        {
            this.serviceBll = serviceBll;
            this.wS010000190 = wS010000190;
        }

        /// <summary>
        /// Extracts the specified extract model.使用paddlenlp提取数据
        /// </summary>
        /// <param name="extractModel">The extract model.提取参数  schema参数说明提取参数 实体抽取["姓名","性别"];关系抽取['法院', {'原告': '委托代理人'}, {'被告': '委托代理人'}] ;事件抽取 {'地震触发词': ['地震强度', '时间', '震中位置', '震源深度']} ;句子级情感倾向分类 情感倾向[正向，负向] </param>
        /// <returns></returns>
        [HttpPost("extract")]
        public async Task<ActionResult> Extract(NlpExtractModel extractModel)
        {
            return Ok(await serviceBll.Extract(extractModel));
        }

        /// <summary>
        /// Extracts the specified extract model.使用paddlenlp提取数据
        /// </summary>
        /// <param name="requestModel">The extract model.提取参数  schema参数说明提取参数 实体抽取["姓名","性别"];关系抽取['法院', {'原告': '委托代理人'}, {'被告': '委托代理人'}] ;事件抽取 {'地震触发词': ['地震强度', '时间', '震中位置', '震源深度']} ;句子级情感倾向分类 情感倾向[正向，负向] </param>
        /// <returns></returns>
        [HttpPost("api/uierecognition")]
        public async Task<ActionResult> UieRecognition(EntityRequest requestModel)
        {
            var r1 = new HttpReturnEntity
            {
                Code = "1",
                Body = await serviceBll.GetUieRexExtract(requestModel)
            };
            return Ok(r1);
        }
        /// <summary>
        /// Extracts the specified extract model.使用paddlenlp提取数据
        /// </summary>
        /// <param name="extractModel"></param>
        /// <returns></returns>
        [HttpPost("api/WS010000190/Extract")]
        public async Task<ActionResult> WS010000190Extract(NlpExtractModel extractModel)
        {
            return Ok(await wS010000190.CreateDateData(extractModel.Id,extractModel.Texts.ToString()));
        }
        /// <summary>
        /// Extracts the specified extract model.使用paddlenlp提取数据
        /// </summary>
        /// <param name="extractModel"></param>
        /// <returns></returns>
        [HttpPost("api/WS010000190/GetExtract")]
        public async Task<ActionResult> WS010000190GetExtract(NlpExtractModel extractModel)
        {
            return Ok(await wS010000190.GetDateData(extractModel.Id));
        }
    }
}